<?php

namespace App\Admin\Controllers\Mining;

use App\Admin\Repositories\Mining\UserMiningShare;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Layout\Content;
use Dcat\Admin\Show;
use Dcat\Admin\Controllers\AdminController;

class UserMiningShareController extends AdminController
{


    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new UserMiningShare(['user','order']), function (Grid $grid) {
            $grid->column('id')->sortable();
            $grid->column('order_id');
            $grid->column('order.product_title');
            $grid->column('user_id');
            $grid->column('user.username');
            $grid->column('amount');
            $grid->column('user_amount');
            $grid->column('company_amount');
            $grid->column('share_amount');
            $grid->column('date');
            $grid->column('created_at');

            $grid->disableCreateButton();
            $grid->disableEditButton();
            $grid->disableDeleteButton();
            $grid->disableBatchDelete();
            $grid->model()->orderBy('id','desc');
            $grid->perPages([5,10,20,50,100,200,500,1000]);
        });
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     *
     * @return Show
     */
    protected function detail($id)
    {
        return Show::make($id, new UserMiningShare(), function (Show $show) {
            $show->field('id');
            $show->field('order_id');
            $show->field('user_mining_id');
            $show->field('user_id');
            $show->field('amount');
            $show->field('user_amount');
            $show->field('company_amount');
            $show->field('share_amount');
            $show->field('date');
            $show->field('created_at');
            $show->field('updated_at');
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new UserMiningShare(), function (Form $form) {
            $form->display('id');
            $form->text('order_id');
            $form->text('user_mining_id');
            $form->text('user_id');
            $form->text('amount');
            $form->text('user_amount');
            $form->text('company_amount');
            $form->text('share_amount');
            $form->text('date');

            $form->display('created_at');
            $form->display('updated_at');
        });
    }
}
